# import requests
# from lxml import etree
# import csv
# import pandas
# def get_html(url):
#     head = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'}
#     try:
#         r = requests.get(url=url,headers=head)
#         r.encoding = r.apparent_encoding
#         r.raise_for_status()
#         return r.text
#     except Exception as e:
#         print(e)
# def parser(html):
#     doc = etree.HTML(html)
#     title = doc.xpath('//div[@id="rankWrap"]/div[2]/ul/li/a/@title')
#     href = doc.xpath('//div[@id="rankWrap"]/div[2]/ul/li/a/@href')
#     out_dicf = {'歌曲':title,'地址':href}
#     return out_dicf
#
# def save_dict2csv(item,path):
#     df = pandas.DataFrame(item)
#     df.to_csv(path)
# if __name__ == '__main__':
#     url = "http://www.bspider.top/kugou/"
#     html = get_html(url)
#     # lujin = 'd.\\kugou.csv'
#     out_dicf = parser(html)
#     save_dict2csv(out_dicf,"d:\\kugou.csv")

import requests
from lxml import etree
import csv
def get_html(url):
    head = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'}
    try:
        r = requests.get(url=url,headers=head)
        r.encoding = r.apparent_encoding
        r.raise_for_status()
        return r.text
    except Exception as err
        print(err)
def parser(html):
    doc = etree.HTML(html)
    out_list = []



def save_csv(item,path):
    with open(path,"a+",newline=",")